package com.wcy.controller.user;

import com.wcy.feign.resource.FeignResourceFileController;
import com.wcy.feign.user.FeignUserFileController;
import com.wcy.util.vo.FileAttribute;
import jakarta.annotation.Resource;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class UserFileController {
    @Resource
    private FeignUserFileController feignUserFileController;

    @PostMapping(value = "user/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public FileAttribute upload(@RequestPart("file") MultipartFile file) {
        return feignUserFileController.upload(file);
    }

    @GetMapping("user/download/{convertedFileName}")
    public ResponseEntity<byte[]> download(@PathVariable("convertedFileName") String convertedFileName) {
        return feignUserFileController.download(convertedFileName);
    }
}